// 导入 echarts 以便使用其图形渐变等功能
import * as echarts from 'echarts'

// 发货数据图表数据
export const getShipmentChartData = () => {
  return {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985'
        }
      },
      formatter: function(params) {
        const date = params[0].name;
        const value = params[0].value;
        return `${date}<br/><span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#0165FF;"></span>订单量: ${value}`;
      }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['2024.01.01', '2024.01.02', '2024.01.03', '2024.01.04', '2024.01.05', '2024.01.06', '2024.01.07']
    },
    yAxis: {
      type: 'value',
      splitLine: {
        lineStyle: {
          type: 'dashed'
        }
      }
    },
    series: [
      {
        name: '订单量',
        type: 'line',
        stack: 'Total',
        smooth: true,
        lineStyle: {
          width: 3,
          color: '#0165FF'
        },
        areaStyle: {
          opacity: 0.3,
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: 'rgba(1, 101, 255, 0.5)' },
            { offset: 1, color: 'rgba(1, 101, 255, 0.1)' }
          ])
        },
        emphasis: {
          focus: 'series'
        },
        data: [500, 1200, 3000, 4500, 3000, 4000, 500],
        markPoint: {
          data: [
            { 
              name: '订单量', 
              coord: ['2024.01.04', 4500], 
              value: '3250',
              symbol: 'circle',
              symbolSize: 8,
              itemStyle: { 
                color: '#fff',
                borderColor: '#0165FF',
                borderWidth: 2
              },
              label: {
                formatter: function(param) {
                  return `${param.name}: ${param.value}`;
                },
                position: 'top',
                distance: 10,
                backgroundColor: '#0165FF',
                padding: [5, 10],
                borderRadius: 5,
                color: '#fff'
              }
            }
          ]
        }
      }
    ]
  }
}

// 未完成订单饼图数据
export const getPendingChartData = () => {
  return {
    tooltip: {
      trigger: 'item',
      formatter: '{b}: {c} ({d}%)'
    },
    legend: {
      orient: 'vertical',
      right: '0',
      top: 'middle',
      itemWidth: 14,
      itemHeight: 14,
      icon: 'circle',
      formatter: '{name}',
      textStyle: {
        color: '#606266'
      },
      itemGap: 12
    },
    series: [
      {
        name: '订单状态',
        type: 'pie',
        radius: ['45%', '70%'],
        center: ['42%', '50%'],
        avoidLabelOverlap: true,
        itemStyle: {
          borderRadius: 0,
          borderColor: '#fff',
          borderWidth: 2
        },
        label: {
          show: true,
          position: 'outside',
          formatter: '{b} {d}%',
          fontSize: 12,
          color: '#606266',
          lineHeight: 18
        },
        labelLine: {
          show: true,
          length: 15,
          length2: 10,
          smooth: false
        },
        emphasis: {
          label: {
            fontSize: 14,
            fontWeight: 'bold'
          }
        },
        data: [
          { value: 55, name: '待称重', itemStyle: { color: '#4cd964' } },
          { value: 15, name: '待拣货', itemStyle: { color: '#007aff' } },
          { value: 8, name: '待验货', itemStyle: { color: '#ff9500' } },
          { value: 5, name: '待打包', itemStyle: { color: '#5856d6' } },
          { value: 17, name: '待作业', itemStyle: { color: '#ff3b30' } }
        ]
      }
    ]
  }
} 